package io.gitee.yth.design.pattern.test.core.pattern.structural.flyweight.code;

import java.util.EnumMap;

/**
 * @author yth
 * @since 2023-04-27-17:33
 */
public class WebSiteFactory {

    private final EnumMap<ConcreteWebSite.Category, ConcreteWebSite> map
            = new EnumMap<>(ConcreteWebSite.Category.class);

    public ConcreteWebSite getWebSiteByCategory(ConcreteWebSite.Category category) {
        if (map.containsKey(category)) {
            return map.get(category);
        } else {
            final ConcreteWebSite webSite = new ConcreteWebSite(category);
            map.put(category, webSite);
            return webSite;
        }
    }

}
